package com.futureway.test.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.futureway.test.dao.OrderItemRespository;
import com.futureway.test.dao.OrderRespository;
import com.futureway.test.entity.Order;
import com.futureway.test.service.OrderService;

@Service
public class OrderServiceImpl implements OrderService {

	@Autowired
	private OrderRespository orderRespository;

	@Autowired
	private OrderItemRespository orderItemRespository;

	@Override
	public String save(Order order) {
		order = orderRespository.save(order);
		return order.getId();
	}

	@Override
	public List<Order> findAll() {
		return (List<Order>) orderRespository.findAll();
	}

	@Override
	public void deleteItem(String itemId) {
		orderItemRespository.deleteById(itemId);
	}

}
